package paint;

import impsoft.scripting.ibot.structs.AryanTile;
import impsoft.scripting.types.ColorSkeltonScriptable;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Polygon;
import java.awt.event.MouseEvent;

public class PaintTile extends PaintComponent implements TimedComponent {
	private AryanTile tile;
	private long expirationTime;
	private ColorSkeltonScriptable c;

	private Color backgroundColor;
	private Color outlineColor;

	public PaintTile(AryanTile tile, long expirationTime, ColorSkeltonScriptable c, Color backgroundColor,
			Color outlineColor) {
		this.tile = tile;
		this.expirationTime = expirationTime + System.currentTimeMillis();
		this.c = c;
		this.backgroundColor = backgroundColor;
		this.outlineColor = outlineColor;
	}

	public PaintTile(AryanTile tile, long expirationTime, ColorSkeltonScriptable c) {
		this.tile = tile;
		this.expirationTime = expirationTime + System.currentTimeMillis();
		this.c = c;
		backgroundColor = new Color(0, 0, 0, 160);
		outlineColor = Color.BLACK;
	}

	@Override
	public boolean isUp() {
		return getExpiration() < 1;
	}

	@Override
	public long getExpiration() {
		return System.currentTimeMillis() - expirationTime;
	}

	@Override
	public boolean hasExpirationTime() {
		return expirationTime > 0;
	}

	@Override
	public void setExpiration(long time) {
		expirationTime = time + System.currentTimeMillis();
	}

	@Override
	public void paint(Graphics g) {
		if (!isUp()) {
			Polygon screenTile = tile.getGameScreenLocation(c, -40, 40, -40, 40, 25, 30);
			if (screenTile != null) {
				g.setColor(backgroundColor);
				g.fillPolygon(screenTile);

				g.setColor(outlineColor);
				g.drawPolygon(screenTile);
			}
		}
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseDragged(MouseEvent e) {
		// TODO Auto-generated method stub

	}

}
